package com.example.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@Configuration
@PropertySource("classpath:db.properties")
public class JDBCConfig {
    @Value("${db_url}")
    private String url;
    @Value("${db_driver}")
    private String driver;
    @Value("${db_username}")
    private String username;
    @Value("${db_password}")
    private String password;

@Bean
public DruidDataSource druidDataSource() {
    DruidDataSource dataSource=new DruidDataSource();
    dataSource.setUrl(url);
    dataSource.setDriverClassName(driver);
    dataSource.setUsername(username);
    dataSource.setPassword(password);

    return dataSource;
}
}
